<?php

namespace App\Model;

use Illuminate\Database\Eloquent\Model;

/**
 * @property string $username
 */
class OAStaff extends Model
{
    protected $table = 'staff';

    protected $fillable = [
        'account',
        'password',
        'username',
        'position_id',
        'roleid',
        'id_card',
        'phone',
        'email',
        'status',
        'address',
        'avatar',
        'sex',
        'nation',
        'birthday',
        'identify',
        'marriage',
        'university',
        'background',
        'job_date',
        'professional',
        'registered_place',
        'native_place',
        'zip_code',
        'telephone',
        'company_email',
        'hiredate',
        'positive_date',
        'expire_date',
        'renew_date',
        'note',
        'current_address',
        'desc',
        'graduate_date',
    ];

    //获取员工角色
    public function getStaffPosition()
    {
        return $this->hasMany('App\Model\OAStaffPosition','staff_id');
    }

    //获取员工部门
    public function getStaffDept()
    {
        return $this->hasMany('App\Model\OAStaffDept','staff_id');
    }

    //获取员工权限
    public function getStaffAuth()
    {
        return $this->hasMany('App\Model\OAStaffAuth','staff_id');
    }

    //获取所有员工列表
    public static function getAllStaff()
    {
        return self::query()->where('status','>',0)->select(['id','username'])->get()->toArray();
    }
}
